package com.yuan.merchant;

import java.lang.reflect.Method;

import com.yuan.common.domain.BaseDomain;

/**
 * 商家
 * 
 * @author Beni
 * 
 */
public class Merchant extends BaseDomain {

	private static final long serialVersionUID = -1245134102229712011L;

	private Integer id; // 自增长id

	private String name; // 商家简称

	private String fullName; // 全名

	private String url; // 商家网址

	private String priority; // 商家评级，可用于展现时商品的优先级

	private String unions; // 联盟

	private Boolean verified; // 是否通过审核

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPriority() {
		return priority;
	}

	public void setPriority(String priority) {
		this.priority = priority;
	}

	public String getUnions() {
		return unions;
	}

	public void setUnions(String unions) {
		this.unions = unions;
	}

	public Boolean getVerified() {
		return verified;
	}

	public void setVerified(Boolean verified) {
		this.verified = verified;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder(
				"<style tyoe='text/css'>table{border-collapse:collapse; } td{border:1px solid blue;}</style>");
		try {
			sb.append("<table>");
			Class goodsClazz = Merchant.class;

			Method[] methods = goodsClazz.getDeclaredMethods();
			for (Method me : methods) {

				if (me.getName().startsWith("get")) {
					sb.append("<tr>");
					sb.append("<td>");
					sb.append(me.getName().replaceAll("get", ""));
					sb.append("</td>");
					sb.append("<td>");
					sb.append(me.invoke(this));
					sb.append("</td>");
					sb.append("</tr>");
				}
			}

			sb.append("</table>");
		} catch (Exception e) {
			return "";
		}
		return sb.toString();
	}
}
